/**************************************
* 4、编写一个非递归算法，将十进制数转换成
* 十六进制数，并输出转换后的数。
***************************************/
#include<stdio.h>
#include<malloc.h>

typedef struct {int* data;int capacity,top; } stack;

stack* stack_new(int capacity){
    stack* s = malloc(sizeof(stack));
    s->capacity = capacity;
    s->top = 0;
    s->data = malloc(sizeof(int)*capacity);
    return s;
}

void stack_del(stack* s){free(s->data);free(s);}

int stack_pop(stack* s){
    if(s->top==0){perror("Empty stack");return 0;}
    return s->data[--s->top];
}

void stack_push(stack* s,int data){if(s->top < s->capacity)s->data[s->top++] = data;}


int main(){
    int m,n;
    stack* a = stack_new(8); // max_int < 2^32 = 16^8, only need capacity of 8
    scanf("%d",&n);
    m = n;
    while(m!=0){
        stack_push(a,m%16);
        m /= 16;
    }
    printf("Hex(%d)=0x",n);
    while(a->top){
        m = stack_pop(a);
        if(m<10)printf("%d",m);
        else putchar('A' - 10 + m);
    }
    putchar('\n');
    stack_del(a);
    return 0;
}